Repository navigation
Fix rosidl_generator_py assuming incorect library names - #149
Merged
Merged
Conversation
Contributor
Author
Contributor
Author
|
Trying Windows with repos file with this and ament/ament_cmake#371 |
rosidl_generator_py was assuming all interface packages being depended
upon call their interface generation target name "${PROJECT_NAME}", but
that's an incorrect assumption. The target name is a required argument
to rosidl_generate_interfaces. This fixes it by exporting the python
library target using an existing CMake macro for that purpose called
rosidl_export_typesupport_targets() and amen_export_targets()
I works by adding a variable
"${PROJECT_NAME}_TARGETS__rosidl_generator_py" which is set when the
interface package is `find_package()`d. That variable contains the
targets generated by `rosidl_generator_py` so that downstream interface
packages can depend on it.
Signed-off-by: Shane Loretz <sloretz@osrfoundation.org>
sloretz
force-pushed
the
fix_python_assuming_library_names
branch
from
January 4, 2022 19:45
277ae86 to
ffb0eea
Compare
Contributor
Author
Contributor
Author
I'm unable to reproduce this failure in a local windows VM. It's flakiness seems to be a known issue: ros2/launch_ros#280 |
Contributor
Author
Contributor
Author
|
CI LGTM, only two windows test failures are rosbag2 ones that are also in the nightly. |
wjwwood
approved these changes
Jan 11, 2022
delete-merged-branch
Bot
deleted the
fix_python_assuming_library_names
branch
January 11, 2022 18:05
mini-1235
added a commit
to mini-1235/ros-rolling
that referenced
this pull request
Sep 27, 2026
…RGETS
Replace the macOS-only patch with a cross-platform one:
- Restore rosidl_generator_py_suffix ("__rosidl_generator_py"), which
ros2/rosidl_python#140 accidentally dropped. The existing dependency
loop then links other interface packages' Python bindings through the
dedicated <pkg>_TARGETS__rosidl_generator_py list again, as intended by
ros2/rosidl_python#149.
- Export the library only in <pkg>_TARGETS__rosidl_generator_py (an
installed export file plus a config extras file) instead of with
ament_export_targets(), which always adds it to <pkg>_TARGETS. C/C++
consumers of an interface package no longer link it.
- Link Python3::Module instead of Python3::Python on all platforms: the
library is only linked by Python extension modules, which get the
CPython symbols from the interpreter that loads them.
rosidl_generator_py is bumped to build 26 so CI rebuilds it, together
with rosidl_core_generators and rosidl_default_generators (so that
rattler-build builds the generator before the interface packages that
use it) and builtin_interfaces (std_msgs' Python bindings link its
Python bindings through the new list). The regression test added in the
previous commit now passes.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Maurice <mauricepurnawan@gmail.com>
mini-1235
added a commit
to mini-1235/ros-rolling
that referenced
this pull request
Sep 27, 2026
…RGETS Replace the patch that compiled the Python bindings into the extension modules with a smaller one that is closer to upstream's original design (ros2/rosidl_python#149): - Restore rosidl_generator_py_suffix ("__rosidl_generator_py"), which ros2/rosidl_python#140 accidentally dropped. The existing dependency loop then links other interface packages' Python bindings through the dedicated <pkg>_TARGETS__rosidl_generator_py list again. - Export the library only in <pkg>_TARGETS__rosidl_generator_py (an installed export file plus a config extras file) instead of with ament_export_targets(), which always adds it to <pkg>_TARGETS. C/C++ consumers of an interface package no longer link it. - Link Python3::Module instead of Python3::Python on all platforms: the library is only linked by Python extension modules, which get the CPython symbols from the interpreter that loads them. Also update the std_msgs regression test as suggested in review: build the C++ consumer with cxx-compiler (no LDFLAGS, like a user environment) instead of compiler('cxx') + clearing LDFLAGS, and depend on ros2-rclpy. No build number bumps: this goes into the full rebuild, which rebuilds all interface packages with the new generator. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Maurice <mauricepurnawan@gmail.com>
mini-1235
added a commit
to mini-1235/ros-rolling
that referenced
this pull request
Sep 27, 2026
…RGETS Replace the patch that compiled the Python bindings into the extension modules with a smaller one that is closer to upstream's original design (ros2/rosidl_python#149): - Restore rosidl_generator_py_suffix ("__rosidl_generator_py"), which ros2/rosidl_python#140 accidentally dropped. The existing dependency loop then links other interface packages' Python bindings through the dedicated <pkg>_TARGETS__rosidl_generator_py list again. - Export the library without ament_export_targets(), which always adds it to <pkg>_TARGETS: install the export set and include it from a config extras file, and keep rosidl_export_typesupport_targets(), which adds the imported target to <pkg>_TARGETS__rosidl_generator_py only. C/C++ consumers of an interface package no longer link it. - Link Python3::Module instead of Python3::Python on all platforms: the library is only linked by Python extension modules, which get the CPython symbols from the interpreter that loads them. Also update the std_msgs regression test as suggested in review: build the C++ consumer with cxx-compiler (no LDFLAGS, like a user environment) instead of compiler('cxx') + clearing LDFLAGS, and depend on ros2-rclpy. No build number bumps: this goes into the full rebuild, which rebuilds all interface packages with the new generator. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Maurice <mauricepurnawan@gmail.com>
traversaro
pushed a commit
to RoboStack/ros-rolling
that referenced
this pull request
Sep 28, 2026
…RGETS Replace the patch that compiled the Python bindings into the extension modules with a smaller one that is closer to upstream's original design (ros2/rosidl_python#149): - Restore rosidl_generator_py_suffix ("__rosidl_generator_py"), which ros2/rosidl_python#140 accidentally dropped. The existing dependency loop then links other interface packages' Python bindings through the dedicated <pkg>_TARGETS__rosidl_generator_py list again. - Export the library without ament_export_targets(), which always adds it to <pkg>_TARGETS: install the export set and include it from a config extras file, and keep rosidl_export_typesupport_targets(), which adds the imported target to <pkg>_TARGETS__rosidl_generator_py only. C/C++ consumers of an interface package no longer link it. - Link Python3::Module instead of Python3::Python on all platforms: the library is only linked by Python extension modules, which get the CPython symbols from the interpreter that loads them. Also update the std_msgs regression test as suggested in review: build the C++ consumer with cxx-compiler (no LDFLAGS, like a user environment) instead of compiler('cxx') + clearing LDFLAGS, and depend on ros2-rclpy. No build number bumps: this goes into the full rebuild, which rebuilds all interface packages with the new generator. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Maurice <mauricepurnawan@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Requires ament/ament_cmake#371
rosidl_generator_py was assuming all interface packages being depended
upon call their interface generation target name
"${PROJECT_NAME}", butthat's an incorrect assumption. The target name is a required argument
to
rosidl_generate_interfaces(). This fixes it by exporting the pythonlibrary target using an existing CMake macro for that purpose called
rosidl_export_typesupport_targets()andament_export_targets().I works by adding a variable
"${PROJECT_NAME}_TARGETS__rosidl_generator_py"which is set when theinterface package is
find_package()d. That variable contains thetargets generated by
rosidl_generator_pyso that downstream interfacepackages can depend on it.
Since targets are being exported, a bug where build time include paths were marked
PUBLICalso needed to be fixed.I discovered this bug while working on ament/ament_cmake#365, and I need it fixed for ros2/rcl_interfaces#133